/* 全局样式 */
:root {
    --primary-color: #ce422b;
    --secondary-color: #f74c00;
    --accent-color: #ff9800;
    --light-color: #fff3e0;
    --dark-color: #212529;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --rust-orange: #ce422b;
    --rust-dark: #a73420;
    --rust-light: #f8d7da;
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --gradient-secondary: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --border-radius: 0.5rem;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 应用容器 */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--light-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(206, 66, 43, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(247, 76, 0, 0.07) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 152, 0, 0.05) 0%, transparent 50%);
}

/* 头部样式 */
.app-header {
    background: var(--gradient-primary);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-weight: 700;
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
}

.app-header .badge {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 0.5rem 0.75rem;
    font-weight: 500;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.app-header .badge:hover {
    background-color: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-2px);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

/* 应用内容区域 */
.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: white;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    overflow-y: auto;
    transition: var(--transition);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar h5 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.sidebar h5::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 3px;
}

/* 知识卡片样式 */
.knowledge-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    border-left: 4px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.knowledge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(206, 66, 43, 0.1), transparent);
    transition: width 0.3s ease;
}

.knowledge-card:hover::before {
    width: 100%;
}

.knowledge-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.knowledge-card h5 {
    color: var(--rust-orange);
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    position: relative;
    z-index: 1;
}

.knowledge-card p {
    color: #6c757d;
    font-size: 0.875rem;
    margin: 0;
    position: relative;
    z-index: 1;
}

/* 侧边栏问题列表 */
.sidebar-question {
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.875rem;
    position: relative;
    overflow: hidden;
}

.sidebar-question::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(206, 66, 43, 0.1), transparent);
    transition: left 0.5s ease;
}

.sidebar-question:hover::before {
    left: 100%;
}

.sidebar-question:hover {
    background-color: var(--rust-light);
    border-color: var(--primary-color);
    transform: translateX(5px);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.7);
}

/* 标签页样式 */
.tab-container {
    display: flex;
    margin-bottom: 1.5rem;
    background-color: white;
    border-radius: var(--border-radius);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.tab-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tab-container:hover::after {
    transform: scaleX(1);
}

.tab-button {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-radius: calc(var(--border-radius) - 2px);
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.tab-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(206, 66, 43, 0.2), transparent);
    transition: left 0.5s ease;
}

.tab-button:hover::before {
    left: 100%;
}

.tab-button:hover {
    background-color: rgba(206, 66, 43, 0.1);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.tab-button.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
    transform: scale(1.02);
}

.tab-button.active::before {
    display: none;
}

.tab-button i {
    margin-right: 0.5rem;
    position: relative;
    z-index: 1;
}

.tab-button span {
    position: relative;
    z-index: 1;
}

/* 标签页内容 */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

.tab-content-animate {
    animation: tabContentPulse 0.3s ease-out;
}

@keyframes tabContentPulse {
    0% { transform: scale(0.98); opacity: 0.7; }
    50% { transform: scale(1.01); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 聊天容器样式 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.3;
}

.messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 3px;
}

.message {
    max-width: 80%;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    animation: messageSlide 0.3s ease-out;
    position: relative;
}

.message-content {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    word-wrap: break-word;
    position: relative;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.message-avatar i {
    font-size: 16px;
    line-height: 1;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 0;
    box-shadow: var(--shadow-sm);
}

.user-message .message-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -10px;
    width: 0;
    height: 0;
    border-left: 10px solid var(--secondary-color);
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

.bot-message {
    align-self: flex-start;
}

.bot-message .message-content {
    background-color: #f1f3f4;
    color: #333; /* 加深文本颜色，提高可读性 */
    border-bottom-left-radius: 0;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--primary-color);
}

.bot-message .message-content::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -10px;
    width: 0;
    height: 0;
    border-right: 10px solid #f1f3f4;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

.message pre {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: calc(var(--border-radius) - 2px);
    padding: 0.75rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    font-size: 0.875rem;
    border-left: 3px solid var(--primary-color);
}

.message code {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    padding: 0.125rem 0.25rem;
    font-size: 0.875rem;
    color: var(--primary-color);
}

.input-area {
    padding: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.message-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    resize: none;
    font-family: inherit;
    transition: var(--transition);
    max-height: 120px;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(206, 66, 43, 0.25);
}

.send-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.send-btn:hover::before {
    width: 100%;
    height: 100%;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 可视化容器样式 */
.visualization-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    min-height: calc(100vh - 200px); /* 确保容器有足够高度 */
    display: flex;
    flex-direction: column;
}

.visualization-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0.7;
}

.topic-selector {
    margin-bottom: 1.5rem;
    position: relative;
}

.topic-selector h5 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
    position: relative;
}

.topic-selector h5::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--gradient-primary);
}

.form-select {
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    transition: var(--transition);
    position: relative;
    background-color: white;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(206, 66, 43, 0.25);
    outline: none;
}

.generate-button {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.generate-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.generate-button:hover::before {
    left: 100%;
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.generate-button:active {
    transform: translateY(0);
}

.generate-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.visualization-output {
    flex: 1;
    margin: 1.5rem 0 0 0;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.visualization-output::before {
    display: none;
}

/* This is the new wrapper created in JS */
.visualization-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.visualization-content-wrapper .chart-title {
    padding: 1rem 1rem 0 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.visualization-content-wrapper .chart-description {
    padding: 0.5rem 1rem;
    color: #6c757d;
}

.visualization-content-wrapper .mermaid {
    flex-grow: 1; /* Make the diagram fill remaining space */
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.visualization-content-wrapper .mermaid svg {
    width: 100%;
    height: 100%;
    max-width: 100%; /* Ensure it doesn't overflow */
}

/* 挑战容器样式 */
.challenges-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.challenges-header h4 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.progress-section {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.progress {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    background: var(--gradient-primary);
    transition: width 0.6s ease;
}

.topic-filter {
    margin-bottom: 1.5rem;
}

.topic-btn {
    border-radius: 50px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.topic-btn.active {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
}

.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.challenge-card {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    border-left: 4px solid var(--primary-color);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.challenge-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.challenge-card h5 {
    color: var(--rust-orange);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.challenge-card .challenge-topic {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.challenge-card .challenge-difficulty {
    align-self: flex-start;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.difficulty-easy {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.difficulty-medium {
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

.difficulty-hard {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.challenge-card .challenge-status {
    margin-top: auto;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

.status-completed {
    color: var(--success-color);
}

.status-locked {
    color: #6c757d;
}

.status-available {
    color: var(--info-color);
}

/* 挑战模态框样式 */
.challenge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1rem;
}

.challenge-modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.challenge-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.challenge-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.challenge-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.challenge-workspace {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.challenge-feedback {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.feedback-success {
    background-color: rgba(40, 167, 69, 0.1);
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.feedback-error {
    background-color: rgba(220, 53, 69, 0.1);
    border-left: 4px solid var(--danger-color);
    color: var(--danger-color);
}

/* 拖拽区域样式 */
.code-snippets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.code-snippet {
    background-color: white;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    cursor: move;
    transition: var(--transition);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.code-snippet:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.code-snippet.dragging {
    opacity: 0.5;
}

.code-target {
    background-color: white;
    border: 2px dashed rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    min-height: 50px;
    margin-bottom: 0.75rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    transition: var(--transition);
}

.code-target.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(206, 66, 43, 0.05);
}

.code-target.filled {
    border-style: solid;
    border-color: var(--success-color);
    background-color: rgba(40, 167, 69, 0.05);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(206, 66, 43, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 992px) {
    .sidebar {
        width: 250px;
    }
    
    .challenges-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* 欢迎界面样式 */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite;
}

.chat-welcome h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.chat-welcome p {
    color: #6c757d;
    max-width: 600px;
    margin-bottom: 2rem;
}

.suggested-questions {
    width: 100%;
    max-width: 800px;
}

.suggested-questions h5 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-weight: 500;
}

.question-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    width: 100%;
}

.suggestion-btn {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--dark-color);
}

.suggestion-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-btn i {
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.suggestion-btn:hover i {
    color: white;
}

/* 消息内容中的标题样式 */
.message.assistant-message h1 {
    color: #c41e3a; /* 使用更深的红色，增强视觉效果 */
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #c41e3a; /* 使用更深的红色，增强视觉效果 */
    padding-bottom: 0.5rem;
}

.message.assistant-message h2 {
    color: #d63447; /* 使用更深的红色，增强视觉效果 */
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.message.assistant-message h3 {
    color: #e74c3c; /* 使用更深的红色，增强视觉效果 */
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

/* 知识点描述样式 */
.topic-description, .chart-type-description {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(206, 66, 43, 0.05);
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
    min-height: 2.5rem;
    transition: all 0.3s ease;
}

.topic-description p, .chart-type-description p {
    margin: 0;
    font-size: 0.85rem;
    color: #444; /* 加深描述文本颜色，提高可读性 */
}

/* 挑战卡片增强样式 */
.challenge-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    background: white;
}

.challenge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.challenge-card:hover::before {
    opacity: 1;
}

.challenge-card .card-body {
    padding: 1.25rem;
}

.challenge-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.challenge-card .difficulty-stars {
    margin-bottom: 0.75rem;
}

/* 难度星星样式 */
.difficulty-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.difficulty-badge .fa-star {
    color: #ddd;
    transition: color 0.3s ease;
}

.difficulty-badge .fa-star.active {
    color: #ffc107;
}

/* 难度等级样式 */
.difficulty-1 { color: #28a745; }
.difficulty-2 { color: #ffc107; }
.difficulty-3 { color: #fd7e14; }
.difficulty-4 { color: #dc3545; }

.challenge-card .card-text {
    font-size: 0.9rem;
    color: #555; /* 加深卡片文本颜色，提高可读性 */
    margin-bottom: 1rem;
}

.challenge-card .topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.challenge-card .topic-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background-color: rgba(206, 66, 43, 0.1);
    color: var(--primary-color);
    border-radius: 12px;
    font-weight: 500;
}

.challenge-card .completed-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--success-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 挑战模态框增强样式 */
.challenge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.challenge-modal-content {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

.challenge-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(206, 66, 43, 0.05);
}

.challenge-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.challenge-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(0, 0, 0, 0.02);
}

/* 挑战工作区样式 */
.challenge-workspace {
    background-color: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.challenge-code-container {
    background-color: #282c34;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.challenge-code-container pre {
    margin: 0;
    color: #abb2bf;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.challenge-code-container .code-line {
    position: relative;
    padding: 0.25rem 0;
}

.challenge-code-container .code-line.drop-zone {
    min-height: 1.5rem;
    border: 1px dashed #5c6370;
    border-radius: 4px;
    margin: 0.25rem 0;
    padding: 0.25rem;
    transition: all 0.3s ease;
}

.challenge-code-container .code-line.drop-zone.drag-over {
    background-color: rgba(206, 66, 43, 0.2);
    border-color: var(--primary-color);
}

.challenge-code-container .code-line .code-snippet {
    display: inline-block;
    background-color: rgba(206, 66, 43, 0.2);
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
    cursor: move;
    font-size: 0.85rem;
    color: white;
}

.challenge-snippets-container {
    background-color: white;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.challenge-snippets-container h6 {
    margin-bottom: 0.75rem;
    color: var(--dark-color);
    font-weight: 500;
}

.challenge-snippets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.challenge-feedback {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.challenge-feedback.success {
    background-color: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: var(--success-color);
}

.challenge-feedback.error {
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: var(--danger-color);
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .app-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100%;
        z-index: 999;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .tab-button {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .tab-button i {
        margin-right: 0.25rem;
    }
    
    .challenges-grid {
        grid-template-columns: 1fr;
    }
    
    .challenge-modal-content {
        max-width: 100%;
        margin: 1rem;
    }
    
    .question-suggestions {
        grid-template-columns: 1fr;
    }
    
    .challenge-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .challenge-snippets {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .app-header {
        padding: 0.75rem 1rem;
    }
    
    .app-header h1 {
        font-size: 1.25rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .code-snippets {
        gap: 0.5rem;
    }
    
    .code-snippet {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

/* 代码块样式 */
.code-block {
    background-color: #2d3748;
    border-radius: 8px;
    margin: 15px 0;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #4a5568;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a202c, #2d3748);
    border-bottom: 1px solid #4a5568;
}

.code-language {
    color: #a0aec0;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-button {
    background: rgba(74, 85, 104, 0.6);
    border: 1px solid #4a5568;
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.copy-button:hover {
    background: rgba(74, 85, 104, 0.9);
    border-color: #718096;
    transform: translateY(-1px);
}

.code-pre {
    margin: 0;
    padding: 16px;
    background: transparent;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    scrollbar-width: thin;
    scrollbar-color: #4a5568 #2d3748;
}

.code-pre::-webkit-scrollbar {
    height: 8px;
}

.code-pre::-webkit-scrollbar-track {
    background: #2d3748;
}

.code-pre::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

.code-pre::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

.code-block pre {
    margin: 0;
    padding: 0;
    background: transparent;
    overflow: visible;
    white-space: pre-wrap;
    word-break: break-word;
    word-wrap: break-word;
    line-height: 1.6;
    font-family: 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
    tab-size: 4;
    -moz-tab-size: 4;
}

.code-block code {
    background: transparent;
    padding: 0;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    word-wrap: break-word;
    line-height: 1.6;
    color: #e2e8f0;
    font-size: 14px;
    tab-size: 4;
    -moz-tab-size: 4;
    display: block;
}

/* 内联代码样式 */
.inline-code {
    background: rgba(74, 85, 104, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    color: #e6db74;
    border: 1px solid #4a5568;
}

/* 响应式代码块 */
@media (max-width: 768px) {
    .code-pre {
        padding: 12px;
    }
    
    .code-block pre {
        font-size: 13px;
    }
    
    .code-block code {
        font-size: 13px;
    }
    
    .code-header {
        padding: 10px 12px;
    }
}

/* 内联代码样式 */
.inline-code {
    background-color: rgba(206, 66, 43, 0.1);
    color: var(--primary-color);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid rgba(206, 66, 43, 0.2);
}

/* 消息内容中的代码块增强样式 */
.message pre {
    background-color: #282c34;
    border-radius: 8px;
    padding: 0;
    margin-top: 1rem;
    overflow: hidden;
    border: 1px solid #3e4451;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: none; /* 移除固定最大高度，让代码块根据内容自适应 */
    min-height: 100px; /* 增加最小高度，让代码框更高 */
    overflow-y: auto; /* 添加垂直滚动 */
    width: 100%; /* 确保代码块宽度占满容器 */
}

.message code {
    background-color: transparent;
    color: #d0d0d0; /* 加深代码颜色，提高可读性 */
    padding: 1rem;
    display: block;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    max-height: none; /* 移除固定最大高度，让代码块根据内容自适应 */
    overflow-y: auto; /* 添加垂直滚动 */
    width: 100%; /* 确保代码块宽度占满容器 */
    white-space: pre-wrap; /* 保持换行但允许自动换行 */
    word-break: break-all; /* 允许在任意字符处换行 */
    word-wrap: break-word; /* 允许长单词换行 */
    tab-size: 4; /* 设置制表符大小为4个空格 */
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px; /* 增加水平滚动条高度 */
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(206, 66, 43, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(206, 66, 43, 0.7);
}

/* 代码块内滚动条样式 */
.code-block::-webkit-scrollbar,
.message pre::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-block::-webkit-scrollbar-track,
.message pre::-webkit-scrollbar-track {
    background: rgba(40, 44, 52, 0.5);
}

.code-block::-webkit-scrollbar-thumb,
.message pre::-webkit-scrollbar-thumb {
    background: rgba(97, 218, 251, 0.5);
    border-radius: 4px;
}

.code-block::-webkit-scrollbar-thumb:hover,
.message pre::-webkit-scrollbar-thumb:hover {
    background: rgba(97, 218, 251, 0.8);
}

/* ================ 代码高亮注释样式改进 ================ */

/* 增强注释的可读性 - 针对Prism tomorrow主题 */
.code-block .token.comment,
.code-block .token.block-comment,
.code-block .token.prolog,
.code-block .token.doctype,
.code-block .token.cdata,
.message .token.comment,
.message .token.block-comment,
.message .token.prolog,
.message .token.doctype,
.message .token.cdata {
    color: #a9a9a9 !important; /* 更亮的灰色 */
    font-style: italic !important;
    opacity: 0.9 !important;
}

/* 确保注释在自动换行时保持良好格式 */
.code-block .token.comment,
.message .token.comment {
    word-break: break-word !important;
    white-space: pre-wrap !important;
}

/* 改进代码块的整体可读性 */
.code-block pre[class*="language-"],
.message pre[class*="language-"] {
    line-height: 1.6 !important;
}

.code-block code[class*="language-"],
.message code[class*="language-"] {
    line-height: 1.6 !important;
}

/* ================ 代码闯关界面样式 ================ */

/* 顶部导航栏 */
.top-nav {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-radius: 0 0 1rem 1rem;
}

.nav-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: #495057;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
}

.back-btn:hover {
    background: #f8f9fa;
    transform: translateX(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-title {
    margin: 0;
    color: #495057;
    font-weight: 600;
    flex: 1;
}

.gradient-text {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* 关卡选择器 */
.level-selector {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.welcome-section {
    margin-bottom: 3rem;
}

.welcome-section h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* 主题卡片 */
.topic-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #ff6b35, #f7931e);
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.topic-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.topic-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.topic-ownership {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
}

.topic-borrowing {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.topic-info h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.25rem;
}

.topic-info p {
    margin: 0;
    color: #7f8c8d;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 关卡预览 */
.levels-preview {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.level-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.level-dot.completed {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.level-dot.current {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    transform: scale(1.1);
}

.level-dot.locked {
    background: #ecf0f1;
    color: #bdc3c7;
}

/* 挑战视图 */
.challenge-view {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.challenge-header h3 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.challenge-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* 进度侧边栏 */
.progress-sidebar {
    position: sticky;
    top: 1rem;
    height: fit-content;
}

.progress-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-title {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #ecf0f1;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.1rem;
}

/* 挑战主要内容 */
.challenge-main {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.challenge-instructions {
    margin-bottom: 2rem;
}

.challenge-instructions h5 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.instructions-content {
    background: #f8f9fa;
    border-radius: 0.75rem;
    padding: 1.5rem;
    border-left: 4px solid #ff6b35;
}

.instructions-content p {
    margin: 0;
    color: #495057;
    line-height: 1.6;
}

/* 代码工作区 */
.code-workspace {
    margin-bottom: 2rem;
}

.code-workspace h5 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-container {
    background: #2d3748;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #4a5568;
}

.code-template {
    padding: 1.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.code-line {
    display: flex;
    align-items: center;
    margin: 0.25rem 0;
    position: relative;
}

.code-line-number {
    color: #718096;
    min-width: 2rem;
    text-align: right;
    margin-right: 1rem;
    user-select: none;
}

.blank-spot {
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed #718096;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    min-width: 120px;
    min-height: 1.5rem;
    display: inline-block;
    color: #a0aec0;
    text-align: center;
    transition: all 0.3s ease;
}

.blank-spot.filled {
    background: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
    color: #e2e8f0;
}

.blank-spot.drag-over {
    background: rgba(206, 66, 43, 0.2);
    border-color: #ff6b35;
}

/* 代码片段 */
.fragment-workspace {
    margin-bottom: 2rem;
}

.fragment-workspace h5 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fragments-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.fragment-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 0.75rem;
    cursor: grab;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    text-align: center;
    border: none;
    position: relative;
    overflow: hidden;
}

.fragment-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.fragment-item:hover::before {
    left: 100%;
}

.fragment-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.fragment-item.dragging {
    opacity: 0.6;
    transform: rotate(5deg);
    cursor: grabbing;
}

.fragment-item.used {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

/* 控制按钮 */
.challenge-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
    padding: 1.5rem 0;
    border-top: 1px solid #ecf0f1;
    background: #f8f9fa;
    border-radius: 0 0 1rem 1rem;
    margin: 0 -2rem -2rem -2rem;
    padding: 1.5rem 2rem;
}

.btn {
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.btn-check {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
    font-weight: 600;
}

.btn-check:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* 结果模态框 */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.result-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.result-success {
    color: #28a745;
}

.result-error {
    color: #dc3545;
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.explanation {
    background: #f8f9fa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    text-align: left;
}

.explanation h6 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.explanation p {
    color: #6c757d;
    margin: 0;
    line-height: 1.5;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .challenge-content {
        grid-template-columns: 1fr;
    }
    
    .progress-sidebar {
        position: static;
    }
    
    .topics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .nav-title {
        align-self: center;
        width: 100%;
        text-align: center;
    }
    
    .back-btn {
        align-self: flex-start;
    }
    
    .welcome-section h2 {
        font-size: 2rem;
    }
    
    .topic-card {
        padding: 1.5rem;
    }
    
    .topic-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .fragments-container {
        grid-template-columns: 1fr;
    }
    
    .challenge-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .challenge-controls .btn {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 576px) {
    .level-selector,
    .challenge-view {
        padding: 0 0.5rem;
    }
    
    .topic-card {
        padding: 1rem;
    }
    
    .challenge-main {
        padding: 1rem;
    }
    
    .code-template {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .code-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .code-line-number {
        min-width: auto;
    }
}